install_or_load_pack <- function(pack){
  
  create.pkg <- pack[!(pack %in% installed.packages()[, "Package"])]
  
  if (length(create.pkg))
    
    install.packages(create.pkg, dependencies = TRUE)
  
  sapply(pack, require, character.only = TRUE)
  
}

packages <- c('ggplot2', 'dplyr', 'latex2exp', 'ggpubr', 
              'stats', 'leqslv', 'VGAM', 'MASS', 'parallel', 
              'plm', 'lqmm', 'tidyverse', 'readstata13')

install_or_load_pack(packages)

# Load main functions 
source('functions.R')
source('utils.R')

# Generate Figure 3 & 4 
source('fig3_fig4.R')

# Fig 5a & Fig 6 
source('applications/homeowner_comment.R')

# Fig 5b & Fig A4
source('application/bureacrat_aaa.R')

# Fig A2a & Fig A2b
source('DGP II/simulations.R')

# Fig A1
source('Smith 11/smith_simulations.R')

